package sioc;

import foaf.User;
import im.CoreIdea;
import im.Status;

import java.util.ArrayList;



public class Forum extends Container{

	private Site hasHost;
	private UserAccount hasModerator;
	private int numThreads;
	private Forum hasParent;
	private ArrayList<Post> posts;
	
	
	
	public Forum() {
		posts = new ArrayList<Post>();
	}
	
	
	
	public void addPost(Post post){
		posts.add(post);
	}
	
	
	/** this method lists the ideas which are in the repository */
	public void listIdeasInTheRepository(){
		for(Post post : posts){
			UserAccount hasCreator = post.getHasCreator();
			User user = hasCreator.getOwner();
			
			for(CoreIdea idea : user.getIdeas()){
				System.out.println(idea.getTitle());
			}
		}
	}
	
	
	/** this method lists the categories for which ideas have been submitted */
	public void listCategoriesForWhichIdeasHaveBeenSubmitted(){
		for(Post post : posts){
			String category = post.getCategory();
			System.out.println(category);
		}
	}
	
	
	/** this method lists tags which used to classify ideas */
	public void listTagsWhichUsedToClassifyIdeas(){
		for(Post post : posts){
			UserAccount hasCreator = post.getHasCreator();
			User user = hasCreator.getOwner();
			
			for(CoreIdea idea : user.getIdeas()){
				System.out.println(idea.getHasTagging());
			}
		}
	}
	
	
	/** this method lists the implemented ideas */
	public void listImplementedIdeas(){
		for(Post post : posts){
			UserAccount hasCreator = post.getHasCreator();
			User user = hasCreator.getOwner();
			
			for(CoreIdea idea : user.getIdeas()){
				if(idea.getHasStatus() == Status.implemented){
					System.out.println(idea.getTitle());
				}
			}
		}
	}
	
	
	/** this method lists the ideas that has at least three ratings */
	public void listIdeasHasAtLeastThreeRatings(){
		for(Post post : posts){
			UserAccount hasCreator = post.getHasCreator();
			User user = hasCreator.getOwner();
			
			for(CoreIdea idea : user.getIdeas()){
				if(idea.hasAtLeastThreeRatings()){
					System.out.println(idea.getTitle());
				}
			}
		}
	}
	
	
	/** this method lists the ideas that has at least two ratings and one ralization */
	public void listIdeasHasAtLeastTwoRatingsAndOneRealization(){
		for(Post post : posts){
			UserAccount hasCreator = post.getHasCreator();
			User user = hasCreator.getOwner();
			
			for(CoreIdea idea : user.getIdeas()){
				if(idea.hasAtLeastTwoRatingsAndOneRealization()){
					System.out.println(idea.getTitle());
				}
			}
		}
	}
	
	
	/** this method lists the most valuable community members who assessed at least three ideas */
	public void listMostValuableCommunityMembers(){
		for(Post post : posts){
			UserAccount hasCreator = post.getHasCreator();
			User user = hasCreator.getOwner();
			ArrayList<CoreIdea> ideas = user.getIdeas();
			
			if(ideas.size() >= 3){
				System.out.println(user.getFirstName() + " " + user.getLastName());
			}
		}
	}
	
}
